package top.maof.book.map;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import top.maof.book.model.Book;
import top.maof.book.model.BookInfo;
import top.maof.book.rank.book.BookHo;
import top.maof.book.rank.book.BookPage;
import top.maof.book.type.HotType;
import top.maof.book.vo.BookVo;

@Mapper
public interface BookMap {
    BookMap INSTANCE = Mappers.getMapper(BookMap.class);

    @Mappings({
            @Mapping(source = "bookInfo.id", target = "bookInfoId"),
            @Mapping(source = "bookInfo.bookId", target = "id", ignore = true),
            @Mapping(source = "bookInfo.clickNum", target = "clickNum"),
            @Mapping(source = "bookInfo.collectionNum", target = "collectionNum"),
            @Mapping(source = "bookInfo.forwardNum", target = "forwardNum"),
            @Mapping(source = "bookInfo.likesNum", target = "likesNum"),
            @Mapping(source = "bookInfo.score", target = "score")
    })
    BookVo toBookVo(Book book, BookInfo bookInfo);


    BookVo toBookVo(Book book);

    BookPage toBookPage(Book book);

    BookPage toBookPage(BookHo bookHo);

    BookHo toBookHo(Book book);

    BookHo toBookHo(Book book, HotType hotType, Integer userId, String ip);
}
